#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 1e6 + 5;

int n, m;
struct Node {
  char op;
  int x, y;
} a[N];
int b[N], num;
int c[N];
int cnt[N];
ll sum[N];
int lowbit(int x) { return x & -x; }
void update(int x, int d) {
  for (int i = x; i <= num; i += lowbit(i))
    cnt[i] += d, sum[i] += 1ll * b[x] * d;
}
int query_cnt(int x) {
  int res = 0;
  for (int i = x; i > 0; i -= lowbit(i)) res += cnt[i];
  return res;
}
ll query_sum(int x) {
  ll res = 0;
  for (int i = x; i > 0; i -= lowbit(i)) res += sum[i];
  return res;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  rep(i, 1, m) cin >> a[i].op >> a[i].x >> a[i].y;
  rep(i, 1, m) b[i] = a[i].y;
  sort(b + 1, b + m + 1);
  num = unique(b + 1, b + m + 1) - b - 1;
  rep(i, 1, m) a[i].y = lower_bound(b + 1, b + num + 1, a[i].y) - b;
  rep(i, 1, m) {
    int x = a[i].x;
    int y = a[i].y;
    if (a[i].op == 'U') {
      if (c[x]) update(c[x], -1);
      c[x] = y;
      if (c[x]) update(c[x], 1);
    } else {
      int u = query_cnt(num) - query_cnt(y - 1);
      ll v = query_sum(y - 1);
      if (x <= u) {
        cout << "TAK\n";
        continue;
      } else {
        x -= u;
        ll w = 1ll * x * b[y];
        if (v >= w)
          cout << "TAK\n";
        else
          cout << "NIE\n";
      }
    }
  }
  return 0;
}